var
	HH_URL = 'https://after.honghekq.com',
	IMG_URL = 'https://after.honghekq.com/',

	LoginIn = '/background/admin/adminLogin', // 登录
	PhoneSendCode = '/background/tbCodeController/sendCode', //发送验证码
	PhoneCheckCode = '/background/admin/checkCode', //校验手机验证码
	LoginOut = '/background/admin/outLogin', //退出登录
	PasswordReset = '/background/admin/resetPassword', //重置密码
	PhoneRepeat = '/background/admin/checkPhone', //检查手机号是否重复

	FileUp = 'https://www.honghekq.com/file/upload', //上传文件

	// 前台接口
	ProvincialGet = '/user/get_provincial', //获取省份
	CityGet = '/user/get_city', //获取城市

	// 视频	
	VideoGet = '/background/produsts/getCustomProdustsByParam', //查询视频列表
	VideoGetcol9 = ' /background/produsts/getCustomProdustsByParam2', // 查询视频列表（格子）
	VideoGetById = '/background/produsts/getCustomProdusts2ById', //通过id查询
	VideoGetById2 = '/background/produsts/getCustomProdusts6ById', //通过id查询2
	VideoAdd = '/background/produsts/insertProdusts', //添加视频
	VideoMod = '/background/produsts/updateProdusts', //修改视频
	VideoModState = '/background/produsts/updateProdustsStatus', //修改视频状态
	VideoDel = '/background/produsts/deleteProdusts', // 删除视频
	getCustomCommunicationPraiseByParam = '/background/communicationPraise/getCustomCommunicationPraiseByParam', //名师交流列表
	insertTbTeacherCommunication = '/background/teacherCommunication/insertTbTeacherCommunication', //添加名师交流

	//名师交流
	MsjlUserGet = '/background/teacherCommunication/getCustomTeacherCommunication2ByParam', //名师交流浏览用户列表
	MsjlGet = '/background/teacherCommunication/getCustomTeacherCommunicationByParam', //查询名师交流列表
	MsjlById = '/background/teacherCommunication/getTbTeacherCommunicationById', //查询名师交流详情
	MsjlAdd = '/background/teacherCommunication/insertTbTeacherCommunication', //添加名师交流
	MsjlDel = '/background/teacherCommunication/deleteTbTeacherCommunication', //删除名师交流

	// 视频类型
	VtypeGet = '/background/produstsType/getCustomProdustsTypeByParam', //查询视频类型列表
	VtypeGetById = '/background/produstsType/getTbProdustsTypeById', //通过id查询
	VtypeAdd = '/background/produstsType/insertProdustsType', //添加视频类型
	VtypeMod = '/background/produstsType/updateProdustsType', //修改视频类型
	VtypeDel = '/background/produstsType/deleteProdustsType', //删除视频类型

	// 来源
	hhSourceGet = '/background/source/getCustomTbSourceByParam', //查询来源列表
	hhSourceMod = '/background/source/updateTbSource', //修改来源
	hhSourceDel = '/background/source/deleteTbSource', //删除来源
	hhSourceGetByIdd = '/background/source/getTbSourceById', //查询来源详情
	hhSourceAdd = '/background/source/insertTbSource', //添加来源
	//讲师 
	LecturerGet = '/background/chatuser/getCustomChatuser11ByParam', //查询讲师列表
	LecturerGetVideo = '/background/produsts/getCustomProdusts7ByParam', //讲师主页视频列表
	LecturerGetVideo = '/background/produsts/getCustomProdusts7ByParam', //讲师主页视频列表
	LecturerGetXX = '/background/offlineCourse/getCustomOfflineCourse4ByParam', //讲师主页线下/实操课
	LecturerGetHD = '/background/answer/getCustomAnswerByParam', //讲师主页回答列表
	LecturerDelHD = '/background/answer/deleteTbAnswer', //讲师主页删除回答

	LecturerGetTW = '/background/questions/getCustomQuestionsByParam', //讲师主页提问列表
	LecturerDelTW = '/background/questions/deleteTbQuestions', //讲师主页删除提问

	LecturerGetById = '/background/chatuser/getCustomChatuser13ById', //查询讲师主页详情
	LecturerAdd = '/background/chatuser/insertChatuser2', //添加讲师
	LecturerMod = '/background/chatuser/updateChatuser2', //修改讲师
	LecturerDel = '/background/chatuser/deleteChatuser2', //删除讲师
	LecturerOPList = '/background/lecturer/getCustomProdusts4ByParam', //讲师主页课程列表
	LecturerLPById = '/background/chatuser/getCustomChatuser12ById', //讲师主页课程详情

	// 问卷调查
	QuestionnaireGet = '/background/surveyBase/getCustomSurveyBaseByParam', //问卷调查查询列表
	QuestionnaireMod = '/background/surveyBase/updateTbSurveyBase', //问卷调查修改
	QuestionnaireDel = '/background/surveyBase/deleteTbSurveyBase', //问卷调查 删除
	QuestionnaireById = '/background/surveyBase/getCustomSurveyBase2ById', //问卷调通过Id查询
	QuestionnaireGet1 = '/background/surveySubmit/getCustomSurveySubmitByParam', //问卷调查详情里的列表 用户回答的列表
	
	
	LecturerOShare = '/background/lecturer/getCustomProdustsCollectByParam3', //课程详情分享列表
	LecturerOCollect = '/background/lecturer/getCustomProdustsCollectByParam', //课程详情收藏列表
	LecturerOPLookList = '/background/lecturer/getCustomProdustsCollectByParam2', //课程详情浏览列表
	LecturerOChild = '/background/lecturer/getCustomComments4ByParam3', //课程详情（子级）
	LecturerOParent = '/background/lecturer/getCustomComments5ByParam', //课程详情（评论）
	LecturerOById = '/background/lecturer/getCustomLecturerById', //通过id查询讲师详情

	// banner
	BannerGet = '/background/configannouncement/getCustomConfigannouncementByParam', //查询banner列表
	BannerTypeGet = '/background/configannouncement/getConfigannouncementByType', //线上类型查询
	BannerGetById = '/background/configannouncement/getConfigannouncementById', //查询banner详情
	BannerAdd = '/background/configannouncement/insertConfigannouncement', //添加banner
	BannerMod = '/background/configannouncement/updateConfigannouncement', //修改banner
	BannerDel = '/background/configannouncement/deleteConfigannouncement', //删除banner

	// 协议
	AgreementGet = '/background/agreement/getCustomAgreementByParam', //查询协议列表
	AgreementGetById = '/background/agreement/getTbAgreementById', //查询协议详情
	AgreementAdd = '/background/agreement/insertTbAgreement', //添加协议
	AgreementMod = '/background/agreement/updateTbAgreement', //修改协议
	AgreementModState = '/background/agreement/updateTbAgreementStatus', //修改协议状态
	AgreementDel = '/background/agreement/deleteTbAgreement', //删除协议

	// 用户
	UserMod = '/background/chatuser/updateChatuser', //修改用户
	UserModStatus = '/background/chatuser/updateChatuserStatus', //修改用户状态
	UserDel = '/background/chatuser/deleteChatuser', //删除用户
	UserGetHome = '/background/chatuser/getCustomChatuser4ById', //查询用户主页
	UserComment = '/background/chatuser/getCustomChatuser5ById', //查询用户主页评论
	UserGet = '/background/chatuser/getCustomChatuser2ByParam', //查询用户列表
	UserGetById = '/background/chatuser/getCustomChatuser3ById', //查询用户详情
	UserAdd = '/background/chatuser/insertChatuser', //添加用户
	UserShare = '/background/chatuser/getCustomChatuser6ById', //用户主页课程（分享课程）
	UserCollection = '/background/chatuser/getCustomChatuser6ById', //用户主页课程（收藏课程）
	UserHistory = '/background/chatuser/getCustomChatuser6ById', //用户主页课程（浏览历史）


	// 评论
	CommentStatus = '/background/comments/updateCommentsStatus', //修改评论状态
	CommentDel = ' /background/comments/deleteComments', //删除评论
	CommentGet = ' /background/comments/getCustomCommentsByParam', //接口名称 查询评论列表
	CommentGetById = ' /background/comments/getCustomComments2ById', //查询评论详情
	CommentZOthers = '/background/comments/getCustomComments3ByParam', //评论点赞（他人点赞）
	CommentZMyself = '/background/comments/getCustomComments3ByParam', //评论点赞（本人点赞）
	CommentChild = '/background/comments/getCustomComments4ByParam', //评论详情评论（子级）

	//管理员
	AdminGetOne = '/background/admin/getTbAdminInfo', //查询个人主页
	AdminGet = '/background/admin/getCustomAdmin2ByParam', //查询管理员
	AdminGetById = '/background/admin/getTbAdminById', //查询管理员详情
	AdminAdd = '/background/admin/insertTbAdminInfo', //添加管理员信息
	AdminMod = '/background/admin/updateTbAdminInfo', //修改管理员信息
	AdminModState = '/background/admin/updateTbAdminStatus', //修改管理员账户状态
	AdminDel = '/background/admin/deleteTbAdmin', //删除管理员

	//线下课
	XXGet = '/background/offlineCourse/getCustomOfflineCourseByParam', //查询线下课列表
	XXGetById = '/background/offlineCourse/getCustomOfflineCourse3ById', //查询线下课详情
	XXById2 = '/background/offlineCourse/getCustomOfflineCourse2ById', // 通过id查询 全部参数
	XXMod = '/background/offlineCourse/updateOfflineCourse', // 修改线下课
	XXModStatus = '/background/offlineCourse/upateOfflineCourseStatus', // 修改线下课状态
	XXDel = '/background/offlineCourse/deleteOfflineCourse', // 删除线下课
	XXAdd = '/background/offlineCourse/insertOfflineCourse', // 添加线下课
	XXBmList = '/background/offlineCourse/getCustomOfflineSignUpByParam', // 线下课报名列表
	XXBmDel = '/background/offlineCourse/deleteTbOfflineSignUp', //删除报名用户
	XXQNum = '/background/offlineCourse/getCourseNumber' //线下课期数
;

function gotonewtabfn(title) {
	$("#indextitle").html(title)
}

function getuserfn() {

	try {
		if (localStorage.getItem('HH_T') == null || localStorage.getItem('HH_T') == "") {
			window.location.href = "temp/login.html";
		} else {
			// 获取当前账号的用户信息
			POSTAJAX(AdminGetById, {
				tbId: JSON.parse(localStorage.getItem('HH_T'))
			}, function(res) {

				if (res.status == 2001) {
					// 登录超时，请重新登录

					window.location.href = "temp/login.html";
				} else {
					// $("#userid").html('	<img src="' + IMG_URL + res.data.tbHeadPortrait + '" class="layui-nav-img">' + res.data.tbName)
				}
			})
		}

	} catch (e) {
		//TODO handle the exception
	}
}

function POSTAJAX(POSTURL, POSTDATA, callback) {
	$.ajax({
		type: 'post',
		url: HH_URL + POSTURL,
		contentType: 'application/json',
		data: JSON.stringify(POSTDATA),
		beforeSend: function(request) {
			request.setRequestHeader("ticket", JSON.parse(localStorage.getItem('HH_T')).ticket);
		},
		dataType: 'json',
		success: function(res) {
			callback(res);
		}
	})
}



function check_id(value) {
	var arrExp = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]; //加权因子 
	var arrValid = [1, 0, "X", 9, 8, 7, 6, 5, 4, 3, 2]; //校验码 
	var regName = /^(?:[\u4e00-\u9fa5]+)(?:·[\u4e00-\u9fa5]+)*$|^[a-zA-Z0-9]+\s?[\.·\-()a-zA-Z]*[a-zA-Z]+$/;
	if (this.realName == '') {
		uni.showToast({
			title: '请输入真实姓名',
			icon: 'none',
			position: 'bottom'
		});
		return false;
	} else if (!regName.test(this.realName)) {
		uni.showToast({
			title: '请输入正确的姓名',
			icon: 'none',
			position: 'bottom'
		});
		return false;
	} else if (/^\d{17}\d|x$/i.test(value)) {
		var sum = 0,
			idx;
		for (var i = 0; i < value.length - 1; i++) {
			// 对前17位数字与权值乘积求和 
			sum += parseInt(value.substr(i, 1), 10) * arrExp[i];
		}
		// 计算模（固定算法） 
		idx = sum % 11;
		// 检验第18为是否与校验码相等 
		return arrValid[idx] == value.substr(17, 1).toUpperCase();
	} else {
		uni.showToast({
			title: '请输入正确的身份证号',
			icon: 'none',
			position: 'bottom'
		});
		return false;
	}
}
